<!DOCTYPE html>
<html xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" lang="zh" xmlns:th="http://www.thymeleaf.org">
<body>
<div th:replace="include/head.html::html"></div>
<div class="layui-fluid layui-form" lay-filter="layuiadmin-form-useradmin">
    <div class="layui-card">
        <!--表格中的数据 并不显示-->
        <div class="layui-card-body">
            <!--数据表格 -->
            <table class="layui-hidden" id="treeTable" lay-filter="treeTable"></table>
        </div>
    </div>
    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="submit" id="submit" value="确认">
    </div>
    <input type="hidden" id="oid" th:field="${bean.oid}"/>
</div>
<script type="text/javascript" th:inline="none">
    var editObj = null, ptable = null, treeGrid = null, tableId = 'treeTable', layer = null;
    layui.use(['jquery', 'treeGrid', 'layer'], function () {
        var $ = layui.jquery;
        treeGrid = layui.treeGrid;//很重要
        layer = layui.layer;
        treeGrid.config.qj_kz_sel=true;
        ptable = treeGrid.render({
            id: tableId
            , elem: '#' + tableId
            , url: 'permission/editRoleJson?oid='+$("#oid").val()
            , cellMinWidth: 100
            , idField: 'oid'//必須字段
            , treeId: 'oid'//树形id字段名称
            , treeUpId: 'parentId'//树形父id字段名称
            , treeShowName: 'title'//以树形式显示的字段
            , heightRemove: [".dHead", 10]//不计算的高度,表格设定的是固定高度，此项不生效
            , height: 'full-60'
            , isFilter: false
            , iconOpen: true//是否显示图标【默认显示】
            , isOpenDefault: true//节点默认是展开还是折叠【默认展开】
            , loading: true
            , method: 'post'
            , isPage: false
            , cols: [[
                {type: 'numbers'}
                ,{type:'checkbox',field:'oid'}
                , {field: 'title', title: '标题'}
                , {field: 'url', title: '链接'}
                , {field: 'permission', title: '权限'}
                , {
                    title: '类型', align: 'center'
                    , templet: function (d) {
                        if (d.type === 1) {
                            return "<span>列表</span>";
                        } else if (d.type === 2) {
                            return "<span>权限</span>";
                        } else {
                            return "";
                        }
                    }
                }
            ]]
            , parseData: function (res) {//数据加载后回调
                return res;
            }
            , onClickRow: function (index, o) {
                //console.log(index,o,"单击！");
            }
            , onDblClickRow: function (index, o) {
                //console.log(index,o,"双击");
            }
            , onCheck: function (obj, checked, isAll) {//复选事件
                //console.log(obj,checked,isAll);
            }
            , onRadio: function (obj) {//单选事件
                //console.log(obj);
            }
        });

    });

</script>
</body>
</html>
